package hlhj.fhp.supreme.fragment

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.javabean.PhoneBean
import hlhj.fhp.supreme.network.Urls
import hlhj.fhp.supreme.utils.JsonCallBack
import kotlinx.android.synthetic.main.serve_fgm.view.*
import android.content.Intent.ACTION_DIAL
import android.net.Uri
import android.support.v4.app.ActivityOptionsCompat
import android.support.v4.app.Fragment
import hlhj.fhp.supreme.activitys.EwmAty
import kotlinx.android.synthetic.main.serve_fgm.*


/**
 * Created by Administrator on 2018\5\9 0009.
 */
class ServeFgm : Fragment(){
    private lateinit var rootView:View
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        rootView=inflater.inflate(R.layout.serve_fgm,null)

        OkGo.post<PhoneBean>(Urls.BaseUrl+Urls.PHONE)
                .params("type","mobile")
                .execute(object : JsonCallBack<PhoneBean>(activity){
                    override fun onSuccess(response: Response<PhoneBean>?) {
                        val bean = response?.body()
                        if (bean?.code==1){
                            rootView.btCall.text="电话${bean?.data.mobile}"
                        }
                    }
                })
        rootView.tv3.text="工作时间：" +
                "周一至周六" +
                "09：00-23：00"
        rootView.btCall.setOnClickListener {
            val intent = Intent(ACTION_DIAL)
            val data = Uri.parse("tel:" + btCall.text.toString())
            intent.setData(data)
            startActivity(intent)
        }
        rootView.img.setOnClickListener {
            val intent = Intent(context, EwmAty::class.java)
            intent.putExtra("type",0)
//            context.startActivity(intent)
            activity.startActivityFromFragment(this,intent,1,ActivityOptionsCompat.makeSceneTransitionAnimation(activity,rootView.img,"ewmImg").toBundle())
        }

        return rootView
    }
}